<?php
if(defined("IZ_ACCNAME")) {
if(substr($_SERVER['SCRIPT_FILENAME'],-11) == 'install.php') {
  $calpath = substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-20);
} else {
  $calpath = substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-9);
}
if(function_exists('mysqli_connect')) {
  $_SESSION['MYSQLi'] = true;
} else {
  $_SESSION['MYSQLi'] = false;
}
if($_GET['act'] == 'logout') {
  $_SESSION = array();
}
if(isset($_REQUEST['p'])) {
  $lang = $_REQUEST['lang'];
  include_once($calpath.'includes/lang/'.$lang.'_core.php');
  include_once($calpath.'includes/lang/'.$lang.'_admin.php');
} else {
  define("STR_INSTIZEIT","Installing iZeit");
  define("STR_INSTALLING","Installing");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>iZeit &#187; <?php echo STR_INSTALLING; ?></title>
<link rel="shortcut icon" href="http://favicon.izeit.nu/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="icon" href="http://favicon.izeit.nu/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="stylesheet" type="text/css" href="includes/main.css" />
<link rel="stylesheet" type="text/css" href="includes/themes/default.css" />
<script type="text/javascript">
function validate() {
    var valid = true;
    if(document.getElementById('mysqlmode').checked) {
        document.getElementById('errhost').style.display = 'none';
        if(document.getElementById('dbhost').value == "") {
            document.getElementById('errhost').innerHTML = '<?php echo ERR_SQLHOSTBLANK; ?>';
            document.getElementById('errhost').style.display = 'block';
            valid = false;
        }
        document.getElementById('erruser').style.display = 'none';
        if(document.getElementById('dbuser').value == "") {
            document.getElementById('erruser').innerHTML = '<?php echo ERR_SQLUSERBLANK; ?>';
            document.getElementById('erruser').style.display = 'block';
            valid = false;
        }    
        document.getElementById('errdatabase').style.display = 'none';
        if(document.getElementById('dbdatabase').value == "") {
            document.getElementById('errdatabase').innerHTML = '<?php echo ERR_SQLDBBLANK; ?>';
            document.getElementById('errdatabase').style.display = 'block';
            valid = false;
        }    
    }
    document.getElementById('errurl').style.display = 'none';
    if(document.getElementById('calurl').value == "") {
        document.getElementById('errurl').innerHTML = '<?php echo ERR_NOCALURL; ?>';
        document.getElementById('errurl').style.display = 'block';
        valid = false;
    }    
    document.getElementById('erradminuser').style.display = 'none';
    if(document.getElementById('adminuser').value == "") {
        document.getElementById('erradminuser').innerHTML = '<?php echo ERR_ADMINUSER; ?>';
        document.getElementById('erradminuser').style.display = 'block';
        valid = false;
    }  
    document.getElementById('erradminpass').style.display = 'none';
    if(document.getElementById('adminpass').value != document.getElementById('adminpass2').value) {
        document.getElementById('erradminpass').innerHTML = '<?php echo ERR_CONFIRMPASSFAIL; ?>';
        document.getElementById('erradminpass').style.display = 'block';
        valid = false;
    }                    
    return valid;
}

</script>
<style type="text/css">
form input.standard { margin-left: 17em; }
a { text-decoration: none; }
#flags img { width: 48px; height: 48px; }
</style>
</head>

<body>
<div id="narrow">
<div id="bannerback" style="width: 50em;"><a href="index.php" id="banner" style="width: 50em;">iZeit Calendar Home</a></div>

<div class="containerbox" style="width: 50em;">  
    <div class="containertitle"><?php echo STR_INSTIZEIT; ?></div>
<?php if($error) { ?>
    <div style="padding: 1em;">
      <?php echo $error; ?>
    </div>
<?php } elseif($_GET['act'] == 'upgrade') {
  if($_SESSION['cpanel'] != 1) {
    $error .= '<p><span>'.ERR_ERRORTEXT.' &#35;113&#58; '.ERR_NOPERMISSION.'</span></p>';
  } else { ?>
    <div style="padding: 1em;">
    <?php if(empty($_GET['step'])) { ?>
    <?php echo sprintf(ERR_IZEITEXISTS, '<strong>'.$dbdatabase.'</strong>'); ?>
    <br />
    <br />
    <form method="get" action="index.php">
      <input type="hidden" name="act" value="upgrade" />
      <input type="hidden" name="step" value="2" />
      <p style="text-align: right;"><input type="submit" name="doupgrade" value="<?php echo STR_NEXT; ?> &gt;" class="nicebutton" /></p>
    </form>
    <?php } else {
      izsql();
      $adminuser = $_SESSION['uname'];
      $dropqry = "DROP TABLE categories,comments,events,settings,tasks,groups,users";
      if(IZ_CALMODE == 'mysql') {
        if($_SESSION['MYSQLi']) {
          global $dblink;
          $currentuserqry = $dblink->query("SELECT `password`, `language` FROM `users` WHERE `name` = '$adminuser'");
          $currentuser = $currentuserqry->fetch_object();
          $currentuserqry->close();
          $dblink->query($dropqry);
        } else {
          $currentuserqry = mysql_query("SELECT `password`, `language` FROM `users` WHERE `name` = '$adminuser'");
          $currentuser = mysql_fetch_object($currentuserqry);
          @mysql_query($dropqry);
        }
      } elseif(IZ_CALMODE == 'postgre') {
        $currentuserqry = pg_query("SELECT password,language FROM users WHERE name = '$adminuser'");
        $currentuser = pg_fetch_object($currentuserqry);
        @pg_query($dropqry);
      } elseif(IZ_CALMODE == 'msq') {
        $currentuserqry = mssql_query("SELECT password,language FROM users WHERE name = '$adminuser'");
        $currentuser = mssql_fetch_object($currentuserqry);
        @mssql_query($dropqry);
      }
      $calmode = IZ_CALMODE;
      $md5pass = $currentuser->password;
      $lang = $currentuser->language;
      $calurl = $_SESSION['IZ_CALURL'];
      $calendarname = $_SESSION['IZ_CALNAME'];
      include($_SESSION['IZ_CALPATH'].'includes/sql.php');
      echo '<br />'.STR_INSTALLCOMPLETE.'<br /><br /><h1 style="text-align: center;"><a href="index.php?act=login">'.STR_LOGIN.'</a></h1>';
    }
    echo '</div>';
  }
} elseif(!isset($_REQUEST['p'])) { ?>
    <div style="padding: 1em; text-align: center;">
    <?php /* Functions.php - line 2692, admin.php - line 127, install.php - line 154 */ ?>
    <table id="flags" style="border: 0; width: 100%; text-align: center; padding: 5px;">
      <tr>
        <td width="25%"><a href="index.php?p=2&amp;lang=cs"><img src="images/lang_cs.png" alt="&#268;esky" style="border:0;" /><br />&#268;esky</a></td>
        <td width="25%"><a href="index.php?p=2&amp;lang=de"><img src="images/lang_de.png" alt="Deutsch" style="border:0;" /><br />Deutsch</a></td>
        <td width="25%"><a href="index.php?p=2&amp;lang=el"><img src="images/lang_el.png" alt="&#917;&#955;&#955;&#951;&#957;&#953;&#954;&#945;" style="border:0;" /><br />&#917;&#955;&#955;&#951;&#957;&#953;&#954;&#945;</a></td>
        <td><a href="index.php?p=2&amp;lang=en"><img src="images/lang_en.png" alt="English" style="border:0;" /><br />English</a></td>
      </tr><tr>
        <td><a href="index.php?p=2&amp;lang=es"><img src="images/lang_es.png" alt="Espa&#241;ol" style="border:0;" /><br />Espa&#241;ol</a></td>
        <td><a href="index.php?p=2&amp;lang=fr"><img src="images/lang_fr.png" alt="Fran&#231;ais" style="border:0;" /><br />Fran&#231;ais</a></td>
        <td><a href="index.php?p=2&amp;lang=hr"><img src="images/lang_hr.png" alt="Hrvatski Jezik" style="border:0;" /><br />Hrvatski Jezik</a></td>
        <td><a href="index.php?p=2&amp;lang=it"><img src="images/lang_it.png" alt="Italiano" style="border:0;" /><br />Italiano</a></td>
      </tr><tr>
        <td><a href="index.php?p=2&amp;lang=ka"><img src="images/lang_ka.png" alt="ქართული" style="border:0;" /><br />ქართული</a></td>
        <td><a href="index.php?p=2&amp;lang=nl"><img src="images/lang_nl.png" alt="Nederlands" style="border:0;" /><br />Nederlands</a></td>
        <td><a href="index.php?p=2&amp;lang=pl"><img src="images/lang_pl.png" alt="Polski" style="border:0;" /><br />Polski</a></td>
        <td><a href="index.php?p=2&amp;lang=pt"><img src="images/lang_pt.png" alt="Portugu&#234;s" style="border:0;" /><br />Portugu&#234;s</a></td>
      </tr><tr>
        <td><a href="index.php?p=2&amp;lang=ro"><img src="images/lang_ro.png" alt="Engleza" style="border:0;" /><br />Engleza</a></td>
        <td><a href="index.php?p=2&amp;lang=ru"><img src="images/lang_ru.png" alt="&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;" style="border:0;" /><br />&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;</a></td>
        <td><a href="index.php?p=2&amp;lang=sl"><img src="images/lang_sl.png" alt="Slovensko" style="border:0;" /><br />Slovensko</a></td>
        <td><a href="index.php?p=2&amp;lang=sr-Cyrl-CS"><img src="images/lang_sr.png" alt="&#1057;&#1088;&#1087;&#1089;&#1082;&#1080; &#1032;&#1077;&#1079;&#1080;&#1082;" style="border:0;" /><br />&#1057;&#1088;&#1087;&#1089;&#1082;&#1080; &#1032;&#1077;&#1079;&#1080;&#1082;</a></td>
      </tr><tr>
        <td><a href="index.php?p=2&amp;lang=sr-Latn-CS"><img src="images/lang_sr.png" alt="Srpski Jezik" style="border:0;" /><br />Srpski Jezik</a></td>
        <td><a href="index.php?p=2&amp;lang=sv"><img src="images/lang_sv.png" alt="Sverige" style="border:0;" /><br />Sverige</a></td>
        <td><a href="index.php?p=2&amp;lang=tr"><img src="images/lang_tr.png" alt="T&#252;rk&#231;e" style="border:0;" /><br />T&#252;rk&#231;e</a></td>
        <td><a href="index.php?p=2&amp;lang=zh-CHS"><img src="images/lang_ch.png" alt="&#31616;&#20307;&#23383;" style="border:0;" /><br />&#31616;&#20307;&#23383;</a></td>
      </tr>
    </table>
    <br />
    Choose your language to continue.<br />
    W&#0228;hlen Sie ihre Sprache um zu fortsetzen.<br />
    Kies een taal om verder te gaan.<br />
    Por favor, selecciona tu idioma para continuar.<br />    
    Escolha o seu idioma para continuar.<br />
    先选择你的语言再继续。<br />    
    Välj ditt språk för att fortsätta.<br />
    Seleziona una lingua per continuare.<br />
    Devam etmek için dil seçimi yapınız.<br />    
    Pro dokončení vyberte váš jazyk.<br />
    Выберите ваш язык для продолжения.<br />
    Aby kontynuować wybierz język.<br />
    Izberite jezik za nadaljevanje.<br />
    Choisissez votre langue pour continuer.<br />
    Επιλεξτε τη γλωσσα σας για να συνεχισετε.<br />
    Alege limba pentru a continua.<br />
    შეარჩიეთ სასურველი ენა.<br />
    </div>
<?php } elseif($_REQUEST['p'] == '2') { ?>
    <div style="padding: 1em;">
  <?php echo STR_INSTDESC; ?><br /><br />
  <form method="post" action="index.php" onsubmit="return validate();">
    <label><?php echo ADM_CALMODE; ?></label>
        <div class="checks">
          <input type="radio" value="text" id="textmode" disabled="disabled" name="calmode" class="nomargin" /><label for="textmode" class="plain"><?php echo ADM_TEXTMODE; ?></label>
          <input type="radio" value="mysql" id="mysqlmode" name="calmode" checked="checked" class="nomargin" /><label for="mysqlmode" class="plain">MySQL</label>
          <input type="radio" value="postgre" id="postgresqlmode" name="calmode" class="nomargin" /><label for="postgresqlmode" class="plain">Postgre</label>
          <input type="radio" value="msq" id="mssqlmode" name="calmode" class="nomargin" /><label for="mssqlmode" class="plain">MSSQL</label>
        </div><br />

    <div id="mysqldiv">
        <label for="dbhost"><?php echo ADM_SQLHOST; ?></label>
        <input type="text" id="dbhost" name="dbhost" size="40" class="standard" value="localhost" />
        <div class="inlineerror" id="errhost">&nbsp;</div>
        <br />

        <label for="dbuser"><?php echo ADM_SQLUSER; ?></label>
        <input type="text" id="dbuser" name="dbuser" size="40" class="standard" />
        <div class="inlineerror" id="erruser">&nbsp;</div>
        <br />
  
        <label for="dbpass"><?php echo ADM_SQLPASS; ?></label>
        <input type="password" id="dbpass" name="dbpass" size="40" class="standard" /><br />
  
        <label for="dbdatabase"><?php echo ADM_SQLDB; ?></label>
        <input type="text" id="dbdatabase" name="dbdatabase" size="40" class="standard" />
        <div class="inlineerror" id="errdatabase">&nbsp;</div>
        <br />
    </div>
  
    <label for="calendarname"><?php echo ADM_CALNAME; ?></label>
    <input type="text" id="calendarname" name="calendarname" size="40" value="iZeit" class="standard" /><br />
        
    <label for="calurl"><?php echo ADM_CALURL; ?></label>
    <input type="text" id="calurl" name="calurl" size="40" class="standard" value="<?php echo 'http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'],0,strlen($_SERVER['PHP_SELF'])-9); ?>" />
        <div class="inlineerror" id="errurl">&nbsp;</div>
        <br />
        <label for="lang"><?php echo ADM_LANGTITLE; ?></label>
          <select name="lang" id="lang">
            <option value="cs"<?php if($lang == 'cs') { echo ' selected="selected"'; } ?>>&#268;esky</option>
            <option value="en"<?php if($lang == 'el') { echo ' selected="selected"'; } ?>>&#917;&#955;&#955;&#951;&#957;&#953;&#954;&#945;</option>
            <option value="en"<?php if($lang == 'en') { echo ' selected="selected"'; } ?>>English</option>
            <option value="es"<?php if($lang == 'es') { echo ' selected="selected"'; } ?>>Espa&#241;ol</option>
            <option value="en"<?php if($lang == 'fr') { echo ' selected="selected"'; } ?>>Fran&#231;ais</option>
            <option value="de"<?php if($lang == 'de') { echo ' selected="selected"'; } ?>>Deutsch</option>
            <option value="hr"<?php if($lang == 'hr') { echo ' selected="selected"'; } ?>>Hrvatski Jezik</option>
            <option value="it"<?php if($lang == 'it') { echo ' selected="selected"'; } ?>>Italiano</option>
            <option value="nl"<?php if($lang == 'nl') { echo ' selected="selected"'; } ?>>Nederlands</option>
            <option value="pl"<?php if($lang == 'pl') { echo ' selected="selected"'; } ?>>Polski</option>
            <option value="pt"<?php if($lang == 'pt') { echo ' selected="selected"'; } ?>>Portugu&#234;s</option>
            <option value="ru"<?php if($lang == 'ru') { echo ' selected="selected"'; } ?>>&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;</option>
            <option value="sr-Cyrl-CS"<?php if($lang == 'sr-Cyrl-CS') { echo ' selected="selected"'; } ?>>&#1057;&#1088;&#1087;&#1089;&#1082;&#1080; &#1032;&#1077;&#1079;&#1080;&#1082;</option>
            <option value="sr-Latn-CS"<?php if($lang == 'sr-Latn-CS') { echo ' selected="selected"'; } ?>>Srpski Jezik</option>
            <option value="sl"<?php if($lang == 'sl') { echo ' selected="selected"'; } ?>>Slovensko</option>
            <option value="sv"<?php if($lang == 'sv') { echo ' selected="selected"'; } ?>>Sverige</option>
            <option value="tr"<?php if($lang == 'tr') { echo ' selected="selected"'; } ?>>T&#252;rkçe</option>
            <option value="zh-CHS"<?php if($lang == 'zh-CHS') { echo ' selected="selected"'; } ?>>&#31616;&#20307;&#23383;</option>
            <?php /* ?>
            <option value="rs"<?php if($lang == 'rs') { echo ' selected="selected"'; } ?>>Српски Језик</option>
            <option value="hr"<?php if($lang == 'hr') { echo ' selected="selected"'; } ?>>Hrvatski Jezik</option><?php */ ?>
          </select>
  
    <label for="adminuser"><?php echo STR_ADMINUSER; ?></label>
    <input type="text" id="adminuser" name="adminuser" size="40" class="standard" />
        <div class="inlineerror" id="erradminuser">&nbsp;</div>
        <br />
  
    <label for="adminpass"><?php echo STR_ADMINPASS; ?></label>
    <input type="password" id="adminpass" name="adminpass" size="40" class="standard" />
        <div class="inlineerror" id="erradminpass">&nbsp;</div><br />
  
    <label for="adminpass2"><?php echo STR_CONFIRMPASS; ?></label>
    <input type="password" id="adminpass2" name="adminpass2" size="40" class="standard" /><br />
  
    <p style="text-align: right;"><input type="submit" name="install" value="<?php echo STR_NEXT; ?> &gt;" class="nicebutton" /></p>
    
    <input type="hidden" name="p" value="3" /><input type="hidden" name="lang" value="<?php echo $lang; ?>" />
    <?php
    if($_GET['act'] == 'upgrade') {
      echo '<input type="hidden" name="act" value="upgrade" />';
    }
    ?>
    </form>
  </div>
<?php } elseif($_POST['p'] == '3') { ?>
    <div style="padding: 1em;">
<?php
  $calmode = $_POST['calmode'];
  $dbhost = $_POST['dbhost']; 
  $dbuser = $_POST['dbuser']; 
  $dbpass = $_POST['dbpass']; 
  $dbdatabase = $_POST['dbdatabase']; 
  $calendarname = $_POST['calendarname'];
  $calurl = $_POST['calurl'];
  $lang = $_POST['lang'];
  if($_POST['adminuser'] == "") { $error .= '<p><strong>'.ERR_ADMINUSER.'</strong></p>'; } else { $adminuser = $_POST['adminuser']; }
  $adminpass = $_POST['adminpass']; 
  $adminpass2 = $_POST['adminpass2'];
  if($adminpass != $adminpass2) {
    $error .= '<p><strong>'.ERR_CONFIRMPASSFAIL.'</strong></p>';
  }
  $serveraddr = strlen($_SERVER['SERVER_ADDR']) > 0 ? md5($_SERVER['SERVER_ADDR']) : md5(gen_id());
  $izsalt = substr($serveraddr,0,10);
  if(!is_writable('includes/data')) {
    if(!chmod('includes/data', 0777)) {
      $error .= '<p><strong>'.ERR_DIROPEN.'</strong>&#58; includes/</p>';
    }
  }
  if(!$error) {
    $dropqry = 'DROP TABLE categories,comments,events,settings,tasks,groups,users';
    echo STR_SAVINGDB;
    if($calmode == 'mysql') {
      if($_SESSION['MYSQLi']) {
        $dblink = mysqli_connect($dbhost,$dbuser,$dbpass,$dbdatabase);
        if(mysqli_connect_errno()) {
           $error .= '<strong>'.ERR_DBCONNECTFAIL.'</strong>&#58;<br />'.mysqli_connect_error();
        }
        $izeitexists = $dblink->query("SHOW COLUMNS FROM `settings`");
        if($izeitexists) {
          if($_POST['upgrade']) {
            $dblink->query($dropqry);
          } else {
            $error .= '<p>'.sprintf(ERR_IZEITEXISTS, '<strong>'.$dbdatabase.'</strong>').'</p>';
          }
        }
      } else {
        $dblink = @mysql_connect($dbhost,$dbuser,$dbpass);
        @mysql_select_db($dbdatabase,$dblink) or $error .= '<p><strong>'.ERR_DBCONNECTFAIL.'</strong>&#58;<br />'.mysql_error().'</p>';
        $izeitexists = @mysql_query("SHOW COLUMNS FROM `settings`");
        if($izeitexists) {
          if($_POST['upgrade']) {
            mysql_query($dropqry);
          } else {
            $error .= '<br /><br />'.sprintf(ERR_IZEITEXISTS, '<strong>'.$dbdatabase.'</strong>').'<br /><br />';        
          }
        }
      }
    } elseif($calmode == 'postgre') {
      $pgconn = pg_connect("host=$dbhost dbname=$dbdatabase user=$dbuser password=$dbpass") or $error .= '<strong>'.ERR_DBCONNECTFAIL.'</strong>&#58;<br />'.pg_last_error().'<br /><br />';
      $izeitexists = @pg_query("SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'settings'");
      if(pg_num_rows($izeitexists) > 0) {
        if($_POST['upgrade']) {
          $dropqry = 'DROP TABLE "categories","comments","events","settings","tasks","groups","users"';
          pg_query($dropqry);
        } else {
          $error .= '<br /><br />'.sprintf(ERR_IZEITEXISTS, '<strong>'.$dbdatabase.'</strong>').'<br /><br />';
        }
      }
    } elseif($calmode == 'msq') {
      $dblink = mssql_connect($dbhost, $dbuser, $dbpass);
      mssql_select_db($dbdatabase, $dblink) or die('&#35;44&#58; '.ERR_DBCONNECTFAIL.'&#58; '.mssql_get_last_message());
      $izeitexists = @mssql_query("SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = 'settings'");
      if($izeitexists) {
        if($_POST['upgrade']) {
          mssql_query($dropqry);
        } else {
          $error .= '<br /><br />'.sprintf(ERR_IZEITEXISTS, '<strong>'.$dbdatabase.'</strong>').'<br /><br />';        
        }
      }
    }
    if(!$error) {
        if(substr($_SERVER['SCRIPT_FILENAME'],-11) == 'install.php') {
          $calpath = substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-20);
        } else {
          $calpath = substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-9);
        }    
        $md5pass = md5($izsalt.$adminpass);
        require($calpath.'includes/sql.php');
        if(!$error) {
          echo '<span style="color: #009c07; font-weight: bold;">OK</span><br />';
        } else {
          echo '<span style="color: #f00; font-weight: bold;">'.ERR_DBCONNECTFAIL.'</span><br />';          
        }
    }
  }
  if(!$error) {
    $sfile = fopen($calpath."includes/data/settings.php", "w");
    if($sfile) {
      $write = '<?php'."\n"
              .'define("IZ_CALMODE","'.$calmode.'");'."\n"
              .'$dbhost = "'.$dbhost.'";'."\n"
              .'$dbuser = "'.$dbuser.'";'."\n"
              .'$dbpass = "'.$dbpass.'";'."\n"
              .'$dbdatabase = "'.$dbdatabase.'";'."\n"
              .'define(\'IZ_SALT\',\''.$izsalt.'\');'."\n"
              .'?>';
      fwrite($sfile, $write);
      fclose($sfile);
    } else {
      $error .= '<p><span style="color: #ff0000; font-weight: bold;">'.ERR_WRITEFILE.'&#58; includes/data/settings.php</span></p>';
    }
  }
if(!$error) {
  echo '<br />'.STR_INSTALLCOMPLETE.'<br /><br /><h1 style="text-align: center;"><a href="index.php?act=login">'.STR_LOGIN.'</a></h1>';
} else {
  echo $error;
  if($izeitexists) { ?>
  <form method="post" action="index.php">
    <input type="hidden" name="calmode" value="<?php echo $calmode; ?>" />
    <input type="hidden" name="dbhost" value="<?php echo $dbhost; ?>" />
    <input type="hidden" name="dbuser" value="<?php echo $dbuser; ?>" />
    <input type="hidden" name="dbpass" value="<?php echo $dbpass; ?>" />
    <input type="hidden" name="dbdatabase" value="<?php echo $dbdatabase; ?>" />
    <input type="hidden" name="calendarname" value="<?php echo $calendarname; ?>" />
    <input type="hidden" name="calurl" value="<?php echo $calurl; ?>" />
    <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
    <input type="hidden" name="adminuser" value="<?php echo $adminuser; ?>" />
    <input type="hidden" name="adminpass" value="<?php echo $adminpass; ?>" />
    <input type="hidden" name="adminpass2" value="<?php echo $adminpass2; ?>" />
    
    <input type="hidden" name="p" value="3" />
    <input type="hidden" name="upgrade" value="1" />
    <input type="button" name="act" value="&lt; <?php echo STR_PREVIOUS; ?>" class="nicebutton" style="float:left;" onclick="history.go(-1)" />
    <p style="text-align: right;"><input type="submit" name="install" value="<?php echo STR_NEXT; ?> &gt;" class="nicebutton" /></p>
  </form>
<?php } } ?>
</div>
<?php } 
if($error) {
  echo '<div style="padding: 1em;">',$error,'</div>';
}
?>
</div></div>
  <?php echo '<p class="gentext"><a href="http://www.izeit.nu/">iZeit by Harry Jennerway</a><br />Copyright &copy;2005-2008 <a href="http://www.lime49.com/">Harry Jennerway</a></p>'; ?>
</body>
</html>
<?php } else {
  // Directly accessed
  header('Location: ../');
} ?>